#include "main/utils.h"
using namespace std;

class Solution {
  public:
    vector<int> twoSum(vector<int>& nums, int target) {
      int len = nums.size();
      for (int i = 0; i < len; ++i) {
        for (int j = i + 1; j < len; ++j) {
          if (nums[i] + nums[j] == target) {
            return {i, j};
          }
        }
      }
      return {};
    }

    vector<int> twoSum1(vector<int>& nums, int target) {
      unordered_map<int, int> hash_map;
      int len = nums.size();
      for (int i = 0; i < len; ++i) {
        auto it = hash_map.find(target - nums[i]);
        if (it != hash_map.end()) {
          return {it->second, i};
        }
        hash_map[nums[i]] = i;
      }
      return {};
    }
};

int main() {
  vector<int> input = {2, 7, 11, 15};
  int target = 9;
  Solution su;
  auto output = su.twoSum(input, target);
  printVec("output", output);
  auto output1 = su.twoSum1(input, target);
  printVec("output", output1);
}
